package com.ktjiaoyu.service.impl;

import com.ktjiaoyu.entity.ComputerRoom;
import com.ktjiaoyu.mapper.ComputerRoomMapper;
import com.ktjiaoyu.service.ComputerRoomService;
import com.ktjiaoyu.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.CompletionService;

/**
 * @author 黄军艳
 * @version 1.0
 * @date 2024/12/24  9:53
 */
@Service("computerRoomService")
public class ComputerRoomServiceImpl implements ComputerRoomService {
    @Autowired
    private ComputerRoomMapper computerRoomMapper;

    @Override
    public Page<ComputerRoom> getPage(ComputerRoom computerRoom, Integer pageNo, Integer pageSize) {
        Page<ComputerRoom> page=new Page<>();
        page.setPageNo(pageNo);
        page.setPageSize(pageSize);

        //总页数
        Integer count=computerRoomMapper.count(computerRoom);
        page.setTotalCount(count);
        Integer pageBegin=(pageNo-1)*pageSize;
        List<ComputerRoom> list=computerRoomMapper.getPage(computerRoom, pageBegin, pageSize);
        page.setData(list);
        return page;
    }

    @Override
    public boolean insert(ComputerRoom computerRoom) {
        return computerRoomMapper.insert(computerRoom)>0;
    }

    @Override
    public boolean delete(Integer roomId) {
        return computerRoomMapper.delete(roomId)>0;
    }

    @Override
    public boolean update(ComputerRoom computerRoom) {
        return computerRoomMapper.update(computerRoom)>0;
    }

    @Override
    public ComputerRoom getId(Integer roomId) {
        return computerRoomMapper.getId(roomId);
    }

    @Override
    public ComputerRoom getRoomName(String roomName) {
        return computerRoomMapper.getRoomName(roomName);
    }
}
